package com.googlecode.kipler.satisfiability.reasoner.profile;

import com.googlecode.kipler.container.dl.creational.ContainerType;
import com.googlecode.kipler.container.dl.creational.WcsFactory;
import com.googlecode.kipler.satisfiability.completion.strategy.CompletionStrategy;
import com.googlecode.kipler.satisfiability.completion.strategy.SHOIQBasicCompletionStrategy;
import com.googlecode.kipler.satisfiability.completion.strategy.SHOIQModifiedIndividualBasedCompletionStrategy;
import com.googlecode.kipler.satisfiability.reasoner.Reasoner;
import com.googlecode.kipler.transformations.SHOIQPreprocessingStrategy;
import com.googlecode.kipler.transformations.SyntacticalProcessingStrategy;

/**
 * 
 * @author İnanç Seylan
 * 
 */
public class SHOIQReasoningProfile implements ReasoningProfile {

	private CompletionStrategy completionStrategy;

	private SyntacticalProcessingStrategy preprocessingStrategy;

	private boolean modifiedIndividualList, logging, backjumping;

	private Reasoner reasoner;

	private ContainerType wcsType;

	private boolean unfoldableTBox;

	public SHOIQReasoningProfile(Reasoner reasoner) {
		this.reasoner = reasoner;
		toggleModifiedIndividualList().toggleModifiedIndividualList();
		preprocessingStrategy = new SHOIQPreprocessingStrategy(reasoner);
		backjumping = true;
		unfoldableTBox = true;
	}

	public CompletionStrategy getCompletionStrategy() {
		return completionStrategy;
	}

	public SyntacticalProcessingStrategy getPreprocessingStrategy() {
		return preprocessingStrategy;
	}

	public String getIdentifier() {
		return "SHOIQ";
	}

	public SHOIQReasoningProfile toggleLogging() {
		logging = !logging;
		return this;
	}

	public boolean isLoggingEnabled() {
		return logging;
	}

	public WcsFactory getWcsFactory() {
		return WcsFactory.getFactory(wcsType, isUnfoldableTBoxEnabled(),
				reasoner);
	}

	public boolean isBackjumpingEnabled() {
		return backjumping;
	}

	public SHOIQReasoningProfile toggleBackjumping() {
		backjumping = !backjumping;
		return this;
	}

	public boolean isModifiedIndividualListEnabled() {
		return modifiedIndividualList;
	}

	public SHOIQReasoningProfile toggleModifiedIndividualList() {
		modifiedIndividualList = !modifiedIndividualList;
		if (modifiedIndividualList) {
			completionStrategy = new SHOIQModifiedIndividualBasedCompletionStrategy(
					reasoner);
			wcsType = ContainerType.SHOIQ_MODIFIED_INDIVIDUAL;
		} else {
			completionStrategy = new SHOIQBasicCompletionStrategy(reasoner);
			wcsType = ContainerType.SHOIQ_BASIC;
		}
		return this;
	}

	@Override
	public boolean isUnfoldableTBoxEnabled() {
		return unfoldableTBox;
	}

	@Override
	public ReasoningProfile toggleUnfoldableTBox() {
		unfoldableTBox = !unfoldableTBox;
		return this;
	}

	@Override
	public boolean isInterpolationEnabled() {
		return false;
	}

	@Override
	public ReasoningProfile toggleInterpolation() {
		return this;
	}

}
